/* 
 * File:   TuringM.h
 * Author: miroslav
 *
 * Created on December 27, 2010, 1:58 AM
 */

#ifndef _TURINGM_H
#define	_TURINGM_H

class TuringM {

    struct Elem {
        int val;
        Elem* next;
        Elem* back;

        Elem(int v) {
            val = v;
        }

        Elem() {
        };
    };

    struct Instruction {
        int trenutnoStanje;
        int trenutniZnak;
        int novoStanje;
        int noviZnak;
        int pravac;
        Instruction* next;

        Instruction(int ts, int tz, int ns, int nz, int r) {
            trenutnoStanje = ts;
            trenutniZnak = tz;
            novoStanje = ns;
            noviZnak = nz;
            pravac = r;
            next = NULL;
        }

        Instruction() {
        };
    };

    struct GlavaTM {
    };

    Elem* head;
    Elem* tail;
    Elem* current;
    Instruction* first, *tmp;

public:
    TuringM();
    TuringM(const TuringM& orig);
    virtual ~TuringM();
    void start();

private:
    void ucitavanje();
    int obrada();

public:
    void add(Elem* e);
    void addHead(Elem* e);
    void addTail(Elem* e);
    void addInstruction(int ts, int tz, int ns, int nz, int r);

    void printStrap();
    void printStrap(char* fileName);

private:
    Instruction* findInstruction(int ts, int tz);
};

#endif	/* _TURINGM_H */

